package com.boot.security.server.dao.order;

import java.util.List;
import java.util.Map;

import com.boot.security.server.model.order.TswOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;



@Mapper
public interface TswOrderDao {

    @Select("select * from tsw_order t where t.id = #{id}")
    TswOrder getById(Long id);

    @Delete("delete from tsw_order where id = #{id}")
    int delete(Long id);

    int update(TswOrder tswOrder);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_order(user_id, address_id, coupon_id, order_state, order_time, order_price, total_discount, actual_payment_amount, sycee_total, order_sycee_total, gross_freight, time_payment, transaction_number, method_payment, account_pay, turnover_time, experience_value, invoice_state, cancel_reason, order_note, order_remark) values(#{userId}, #{addressId}, #{couponId}, #{orderState}, #{orderTime}, #{orderPrice}, #{totalDiscount}, #{actualPaymentAmount}, #{syceeTotal}, #{orderSyceeTotal}, #{grossFreight}, #{timePayment}, #{transactionNumber}, #{methodPayment}, #{accountPay}, #{turnoverTime}, #{experienceValue}, #{invoiceState}, #{cancelReason}, #{orderNote}, #{orderRemark})")
    int save(TswOrder tswOrder);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswOrder> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
